package com.bestvike.stone.spring.trace;

import com.bestvike.stone.spring.boot.ApplicationProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by 许崇雷 on 2018-01-27.
 */
@Configuration
@EnableConfigurationProperties(ApplicationProperties.class)
public class TraceAutoConfiguration {
    private final ApplicationProperties applicationProperties;

    public TraceAutoConfiguration(ApplicationProperties applicationProperties) {
        this.applicationProperties = applicationProperties;
    }

    @Bean
    @ConditionalOnMissingBean
    ISequence sequence() {
        return new Sequence();
    }

    @Bean
    @ConditionalOnMissingBean
    ITracer tracingTracer(ISequence sequence) {
        return new Tracer(this.applicationProperties.getName(), sequence);
    }
}
